<nav class="navbar navbar-inverse">
    <div class="container">
        <!-- Brand and toggle get grouped for better mobile display -->
        <div class="navbar-header">
            <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
                <span class="sr-only">Toggle navigation</span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button>
            <a class="navbar-brand" href="/">WjdBobBlog</a>
        </div>
        <!-- Collect the nav links, forms, and other content for toggling -->
        <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
            <ul class="nav navbar-nav">
                <li class="">
                    <a href="/"><span class="glyphicon glyphicon-home"></span> 首页</a>
                </li>
                {% for category in category_list %}
                <li class=""><a href="{% url 'blog:category_detail' category.pk %}">{{ category.name }}</a></li>
                {% endfor %}
            </ul>
            <ul class="nav navbar-nav navbar-right">
                {% if  request.session.is_login %}
                    <li class="dropdown">
                        <a href="javascript:;" style="padding:5px;" data-toggle="dropdown">
                            <img src="{{ MEDIA_URL }}{{ user.image }}" width="40" height="40">&nbsp;
                            {{ user.username }}
                            <span class="badge" style="background-color: #3e8f3e;">{{ user.au }}</span>
                        </a>
                        <ul class="dropdown-menu navbar-right">
                            <li>
                                <a href="{% url 'blog:article_create' %}">
                                    <span class="glyphicon glyphicon-user"></span>
                                    发表文章
                                </a>
                            </li>
                            <li>
                                <a href="{% url 'AppLogin:changeimage' %}">
                                    <span class="glyphicon glyphicon-user"></span>
                                    更改头像
                                </a>
                            </li>
                            <li>
                                <a href="{% url 'AppLogin:changepassword' %}" >
                                    <span class="glyphicon glyphicon-user"></span>
                                    密码修改
                                </a>
                            </li>
                            <li>
                                <a href="{% url 'AppLogin:logout' %}">
                                    <span class="glyphicon glyphicon-log-out"></span>
                                    退出
                                </a>
                            </li>
                        </ul>
                    </li>
                {%else%}
                    <li>
                        <a href="{% url 'AppLogin:login' %}" id="nav-login" data-toggle="modal">登陆</a>
                    </li>
                    <li>
                        <a href="{% url 'AppLogin:register' %}" id="nav-register" data-toggle="modal">注册</a>
                    </li>
                {% endif %}
            </ul>
	    <form class="navbar-form navbar-right" id="searchform" action="{% url 'blog:search' %}" method="get" role="search">
                <div class="form-group">
                    <input type="text" name="q" class="form-control" placeholder="请输入搜索关键字">
                </div>
                <button type="submit" class="btn btn-info">搜索</button>
            </form>
        </div><!-- /.navbar-collapse -->

    </div><!-- /.container-fluid -->
</nav>
